export default {
    bind:function (el, binding, vnode) {
        //监听document是因为如果监听元素el的话鼠标太快移出元素后就会失效
        el.onmousedown = (event) => {
            //算出鼠标相对元素的位置
//			var box=document.getElementById(binding.arg);   
			el.style.cursor = "w-resize"
			el.style.display = "block"
			let oldclientX = event.clientX;
            let pointX = event.clientX - el.offsetLeft;//鼠标位置X减去元素距离左边距离（鼠标到元素左边的距离）
            let oldleft = '';   
            binding.value.self.rowlineclicked = true;
            let oldtemp = 0;
            document.onmousemove = (e)=>{
                //用鼠标的位置减去鼠标相对元素的位置，得到元素的位置
				el.style.cursor = "w-resize"
				el.style.display = "block"
				el.style.top="";
				el.style.left="";
				el.style.right="";
				el.style.bottom="";              
                let left = e.clientX - pointX;   
                let tempx = e.clientX - oldclientX  
                let temp = tempx - oldtemp; 
                oldtemp = tempx;
            //移动当前元素    
	            if((tempx + binding.value.param) > 10){
	            	el.style.left = left + 'px'; 
	            	oldleft = el.style.left	            	
            		let i = binding.value.row;
					let j = binding.value.col;
            		binding.value.func(tempx + binding.value.param,i,j,temp);	
	            }else{	           
	            	el.style.top = oldleft;
	            }
            };
            document.onmouseup = (e) => {
            	binding.value.self.rowlineclicked = false; 
            	binding.value.self.cursor = "";
                document.onmousemove = null;
                document.onmouseup = null;
            };
        };
    },
    update () {

    },
    unbind (el, binding) {
        
    }
};